#ifndef BASECTF_H
#define BASECTF_H

#include <iostream>

// basic structures, constants, etc. for CTF game objects, to be used in the
//  interface between back end and front end
// These are meant for very basic units of information which will probably never
//  need to be broken down further.  For example, we don't have a Camper structure,
//  because the back end might choose not to represent each camper in a single
//  structure; rather than force it to pack its camper data into some struct
//  every time the front end asks for it, the front end can instead call
//  getCamperPos(), getCamperStrength(), etc.  Similarly, a map tile will have
//  several attributes--terrain, presence of walls/fences, player visibility--but
//  the terrain type is basically just some number, so that can be defined here.



#define GRIDTYPE_SQUARE 0
#define GRIDTYPE_HEX 1

// position on the tile grid--can be used for either hex or square grid
// (hex grid is just a square grid with every other column shifted down half
//  a square)
struct GridPos
{
	int x, y;
	// valid == false indicates null/unknown position
	bool valid;

	GridPos(int xx, int yy) : valid(true), x(xx), y(yy) {}
	GridPos() : valid(false), x(-1), y(-1) {}

	void serialize(std::ostream& ostr) const;
	void unserialize(std::istream& istr);
};

// directions on the grid
#define SQ_N 0x1
#define SQ_E 0x2
#define SQ_S 0x4
#define SQ_W 0x8
#define HEX_N 0x1
#define HEX_NE 0x2
#define HEX_SE 0x4
#define HEX_S 0x8
#define HEX_SW 0x10
#define HEX_NW 0x20

// terrain types for map tiles
#define TERRAIN_UNKNOWN 0
#define TERRAIN_GRASS 1
#define TERRAIN_DIRT 2
#define TERRAIN_TREE 3
#define TERRAIN_ROCKS 4
#define TERRAIN_MUD 5
#define TERRAIN_GRAVEL 6
#define TERRAIN_CORNFIELD 7
#define TERRAIN_STREAM 8
#define TERRAIN_POND 9
#define TERRAIN_SAND 10
#define TERRAIN_ROAD 11
#define TERRAIN_CONCRETE 12
#define TERRAIN_WOOD 13
#define TERRAIN_BRUSH 14

// a turn in the game
struct Turn
{
	// 0-based player number, or -1 for the server's turn (at game startup, or in
	//  between player turns, etc.)
	int playerID;
	// 0-based turn number, defined only for actual player turns
	int turnID;

	void serialize(std::ostream& ostr) const;
	void unserialize(std::istream& istr);
};
#define PLAYERID_SERVER -1

// camper stances
#define STANCE_RUN 0
#define STANCE_WALK 1
#define STANCE_CRAWL 2
#define STANCE_STAND 3



#endif // BASECTF_H